package keyintegrity.orm.jpa;

/**
 *
 * @author dmitrygusev
 */
public class StorageException extends Exception {

    /**
	 * 
	 */
	private static final long serialVersionUID = -4271898365908431781L;

	private final Storage storage;
	
    public StorageException(Storage storage, Exception e) {
        super(e);
        this.storage = storage;
    }

    public Storage getStorage() {
		return storage;
	}
    
	@Override
    public String getMessage() {
		return storage == null || storage.getDecorator() == null 
			 ? getSuperMessage()
			 : storage.getDecorator().getMessage(storage, this);
    }

	public String getSuperMessage() {
		return super.getMessage();
	}
} 